package com.weixing.mall.provider.controller.admin;

import com.weixing.mall.base.wrapper.Result;
import com.weixing.mall.base.wrapper.ResultUtil;
import com.weixing.mall.core.support.BaseController;
import com.weixing.mall.provider.model.dto.LeaveMessageReplyDto;
import com.weixing.mall.provider.model.query.LeaveMessageQuery;
import com.weixing.mall.provider.service.ILeaveMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author wx
 * @Date 2019/9/17 14:57
 * @Version 1.0
 */
@RestController
@RequestMapping("leaveMessage")
@Api(value = "留言API",tags = "留言")
public class LeaveMessageController extends BaseController {

    @Autowired
    private ILeaveMessageService leaveMessageService;

    @ApiOperation("查询")
    @GetMapping("")
    public Result selectList(LeaveMessageQuery leaveMessageQuery){
        return ResultUtil.success(leaveMessageService.selectList(initMpPage(),leaveMessageQuery));
    }

    @ApiOperation("回复")
    @PostMapping("reply")
    public Result reply(@RequestBody LeaveMessageReplyDto leaveMessageReplyDto){
        leaveMessageService.reply(leaveMessageReplyDto);
        return ResultUtil.success();
    }

    @ApiOperation("查询详情")
    @PostMapping("selectDetail/{id}")
    public Result selectDetail(@PathVariable long id){
        return ResultUtil.success(leaveMessageService.selectDetail(id));
    }
    @ApiOperation("删除")
    @PostMapping("del/{id}")
    public Result del(@PathVariable Long id){
        return leaveMessageService.removeById(id)  ? ResultUtil.success() : ResultUtil.error();
    }
}
